package response

import "github.com/gin-gonic/gin"

type Code int

var (
	FailedCode  Code = 2001 //通用错误代码
	SuccessCode Code = 2000 //通用成功
)

func Failed(ctx *gin.Context, code Code, err string) {
	ctx.JSON(200, gin.H{
		"code": code,
		"msg":  "failed",
		"err":  err,
	})
}

func Success(ctx *gin.Context, code Code, data any) {
	ctx.JSON(200, gin.H{
		"code": code,
		"msg":  "success",
		"data": data,
	})
}
